# -*- coding: utf-8 -*-
# בש״ד
#
# Miramar CMS for Django - Part of the Cuba Libre Project
# Copyright (C) 2009, Joshua "jag" Ginsberg <jag@flowtheory.net>
# 
# Por mi amor, que inspira a mi cada respiración y que echa de Cuba
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from django.conf.urls.defaults import *

urlpatterns = patterns(
    '',

    ### IMAGE LIBRARY ###
    
    url(r'^_imagelibrary/$',
        'miramar.views.storedimage_list',
        name='miramar_storedimage_list'),
    
    url(r'^_imagelibrary/_create/$',
        'miramar.views.storedimage_create',
        name='miramar_storedimage_create'),
        
    url(r'^_imagelibrary/(?P<slug>[A-Za-z0-9_-]+)/$',
        'miramar.views.storedimage_update',
        name='miramar_storedimage_update'),
    
    url(r'^_imagelibrary/(?P<slug>[A-Za-z0-9_-]+)/delete/$',
        'miramar.views.storedimage_delete',
        name='miramar_storedimage_delete'),

    ### FILE LIBRARY ###

    url(r'^_filelibrary/$',
        'miramar.views.storedfile_list',
        name='miramar_storedfile_list'),
    
    url(r'^_filelibrary/_create/$',
        'miramar.views.storedfile_create',
        name='miramar_storedfile_create'),
        
    url(r'^_filelibrary/(?P<slug>[A-Za-z0-9_-]+)/$',
        'miramar.views.storedfile_update',
        name='miramar_storedfile_update'),
        
    url(r'^_filelibrary/(?P<slug>[A-Za-z0-9_-]+)/delete/$',
        'miramar.views.storedfile_delete',
        name='miramar_storedfile_delete'),
        
    ### PAGES AND PAGE VERSIONS ###

    # The basic page view of the published revision
    url(r'^(?P<slug>[A-Za-z0-9_-]+)/$',
        'miramar.views.page_detail',
        name='miramar_page_detail'),

    # Create a new page
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'create/$'),
        'miramar.views.page_create',
        name='miramar_page_create'),

    # Update the basics of a page itself
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'update/$'),
        'miramar.views.page_update',
        name='miramar_page_update'),

    # Update the basics of a page itself
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'rename/$'),
        'miramar.views.page_rename',
        name='miramar_page_rename'),
    
    # Page view of the most recent revision of a certain version tag
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'(?P<version_tag>[A-Za-z0-9_-]+)/$'),
        'miramar.views.page_detail',
        name='miramar_page_detail_with_tag'),

    # Page view of an explicit version tag and revision number
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'(?P<version_tag>[A-Za-z0-9_-]+)/'
         r'(?P<revision>[0-9]+)/$'),
        'miramar.views.page_detail',
        name='miramar_page_detail_with_revision'),

    # Branch a version tag of a page into a new version tag
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'branch/'
         r'(?P<version_tag>[A-Za-z0-9_-]+)/'
         r'(?P<revision>[0-9]+)/$'),
        'miramar.views.pageversion_branch',
        name='miramar_pageversion_branch'),

    # Update the contents of a revision itself, saving as a new revision
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'update/'
         r'(?P<version_tag>[A-Za-z0-9_-]+)/$'),
        'miramar.views.pageversion_update',
        name='miramar_pageversion_update'),

    # View the differences between two revisions of the same version tag
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'diff/'
         r'(?P<version_tag_a>[A-Za-z0-9_-]+)/'
         r'(?P<revision_a>[0-9]+)/$'),
        'miramar.views.pageversion_diff_form',
        name='miramar_pageversion_diff_form'),

    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'diff/'
         r'(?P<version_tag_a>[A-Za-z0-9_-]+)/'
         r'(?P<revision_a>[0-9]+)/'
         r'(?P<version_tag_b>[A-Za-z0-9_-]+)/'
         r'(?P<revision_b>[0-9]+)/$'),
        'miramar.views.pageversion_diff',
        name='miramar_pageversion_diff'),

    # Approve a given version of a page for publishing
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'approve/'
         r'(?P<version_tag>[A-Za-z0-9_-]+)/'
         r'(?P<revision>[0-9]+)/'),
        'miramar.views.pageversion_approve',
        name='miramar_pageversion_approve'),

    # Publish a given version of a page
    url((r'^(?P<slug>[A-Za-z0-9_-]+)/'
         r'publish/'
         r'(?P<version_tag>[A-Za-z0-9_-]+)/'
         r'(?P<revision>[0-9]+)/'),
        'miramar.views.pageversion_publish',
        name='miramar_pageversion_publish'),
)
